package loadbalance;

import com.alibaba.nacos.api.naming.pojo.Instance;

import java.util.List;

public class RobinLoadBalance implements LoadBalance{
    private int i = 0;
    @Override
    public Instance select(String serviceName, List<Instance> instances) {
        if(i > instances.size()){
            i %= instances.size();
        }
        Instance instance = instances.get(i++);
        return instance;
    }
}
